package cn.edu.hbwe.book.admin.servlet.order;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.hbwe.book.admin.service.order.OrdersService;
import cn.edu.hbwe.book.entity.Orders;

/**
 * Servlet implementation class FindOrderConditionServlet
 */
public class FindOrderConditionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 获取订单编号和收件人名称
		String id = request.getParameter("id");
		String receieverName = request.getParameter("receieverName");
		// 创建Service层对象
		OrdersService service = new OrdersService();
		// 调用Service层OrderService类的findOrderByManyCondition()方法查询数据
		List<Orders> orders = service.findOrderCondition(id, receieverName);
		// 将查询结果添加到request作用域中
		request.setAttribute("orders", orders);
		// 请求转发到list.jsp页面，并将request请求和response响应也转发到该页面中
		request.getRequestDispatcher("/admin/orders/list.jsp").forward(request, response);
	}

}
